package com.platform;

import com.platform.filter.UserFileter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;


import javax.servlet.MultipartConfigElement;

@EnableCaching//开启redis缓存
@SpringBootApplication
@MapperScan("com.platform.dao")
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Bean
    public FilterRegistrationBean UserFileter() {
        FilterRegistrationBean registration = new FilterRegistrationBean(new UserFileter());
        registration.addUrlPatterns("/menuController/*"); //
        registration.addUrlPatterns("/pascController/*");
        registration.addUrlPatterns("/psaa0001Controller/*");
        registration.addUrlPatterns("/psad0001Controller/*");
        registration.addUrlPatterns("/enumController/*");
        registration.addUrlPatterns("/permissionController/*");
        registration.addUrlPatterns("/roleController/*");
        registration.addUrlPatterns("/roleMenuController/*");
        registration.addUrlPatterns("/rolePermissionController/*");
        registration.addUrlPatterns("/rolePermissionController/*");
        registration.addUrlPatterns("/userRoleController/*");
        registration.addInitParameter("paramName", "paramValue"); //
        registration.setName("userFileter");
        return registration;
    }

    /**
     * 文件上传配置
     * @return
     */
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大
        factory.setMaxFileSize("102400KB"); //KB,MB
        /// 设置总上传数据总大小
        factory.setMaxRequestSize("102400KB");
        return factory.createMultipartConfig();
    }
}
